<?php

/**
 * Created by JetBrains PhpStorm.
 * User: root
 * Date: 10/6/12
 * Time: 8:54 AM
 * To change this template use File | Settings | File Templates.
 */
abstract class MVC_AbstractController
{

    protected $uriSegments;

    public function __construct()
    {
        $this->uriSegments = explode('/', trim(str_replace(Config::get('app.url'), '', Util::getUrl('page')), '/'));

    }

    public function __call($name, $arguments)
    {
        $this->show404();

    }

    public function show404()
    {

        return $this->redirect($this->getLink('Content', 'Error', 'show404'));

    }

    public function redirect($url)
    {
        fURL::redirect($url);

    }

    public function getLink($module, $controller, $action, $params = array(), $retainOtherParams = FALSE)
    {
        if (Config::get('app.router') && (Config::get('app.router') instanceof Router_Abstract))
        {
            return Config::get('app.router')->getLink($module, $controller, $action, $params, $retainOtherParams);
        } else
        {
            throw new Exception("Router NOT Set");
        }

    }

}